<?php

namespace App\Services\AetherUpload\Lib;

use App\Services\AetherUpload\Eloquent\DriverResource;


class LocalResource extends DriverResource
{

    /**
     * @param $path
     * @param $data
     * @param int $options
     * @return false|int
     */
    public function append($path, $data, int $position = 0)
    {
        return file_put_contents($this->getRealPath(), $data, FILE_APPEND);
    }

    /**
     * @return false|string
     */
    public function calculateHash()
    {
        return md5_file($this->getRealPath());
    }

    /**
     * @return string
     */
    private function getRealPath(): string
    {
        return $this->config['root'] . '/' . $this->path;
    }
}

